<template>
  <div class="shadow-overlay">
    <div class="custom-card-container" :style="cardStyle">
      <div class="custom-card-title">
        <el-image class="title-img" :src="url" fit="cover" />
        <p class="title-text">{{ title }}</p>
        <p>
          <slot name="titleRight">

          </slot>
        </p>
      </div>
      <div class="custom-card-content">
        <!-- 内容插槽 -->
        <slot name="content"></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CustomCard',
  props: {
    title: {
      type: String,
      default: ''
    },
    height: {
      type: [String, Number],
      default: '282',
      validator: value => !isNaN(parseFloat(value))
    },
    width: {
      type: [String, Number],
      default: '535',
      validator: value => !isNaN(parseFloat(value))
    },
    url: {
      type: String,
      default: require('@/assets/img/title-icon.png')
    }
  },
  data() {
    return {
      rootFontSize: 14,
      resizeObserver: null,

    }
  },
  computed: {
    // 计算属性：将像素值转换为 rem 值

    cardStyle() {
      return {
        height: `${parseFloat(this.height) / this.rootFontSize}rem`,
        width: `${parseFloat(this.width) / this.rootFontSize}rem`
      };
    }
  },

}

</script>
<style scoped lang='scss'>
.shadow-overlay {}

.custom-card-container {
  background-image: url('@/assets/img/card.png');
  background-position: top;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow: 1px 1px 6px 3px #ccc;

  .custom-card-title {
    display: flex;
    align-items: center;
    padding: 15px;


    .title-img {
      width: 20px;
      height: 20px;
    }

    .title-text {
      padding: 0 12px;
      font-family: MicrosoftYaHei-Bold;
      font-size: 20px;
      color: #192C7D;
      letter-spacing: 0;
      line-height: 26px;
      font-weight: 700;
    }
  }
}
</style>